package com.example.mytest.Entity;


import javax.persistence.*;
import java.util.Date;

/**
 * Created by Studio on 2017/5/19.
 */
@Entity
@Table(name = "tbl_msg", schema = "mytest", catalog = "")
public class MessageEntity {


    private int msgId;
    private String objId;
    private String phone;
    private String receiver;
    private String type;
    private Date createTime;
    private Date updateTime;
    private int version;

    @Id
    @Column(name = "msg_id")
    public int getMsgId() {
        return msgId;
    }


    public void setMsgId(int msgId) {
        this.msgId = msgId;
    }

    @Basic
    @Column(name = "obj_id")
    public String getObjId() {
        return objId;
    }

    public void setObjId(String objId) {
        this.objId = objId;
    }

    @Basic
    @Column(name = "phone")
    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Basic
    @Column(name = "receiver")
    public String getReceiver() {
        return receiver;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    @Basic
    @Column(name = "type")
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Basic
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "update_time")
    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Basic
    @Column(name = "version")
    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    public boolean timeOut(){
        long now = new Date().getTime();
        long created = createTime.getTime();

        return now - created / 1000 > 60;
    }
}
